Skip to content

[ExecuTorch][WebGPU] Add select/boolean ops (where, scalar compares, logical_not) to the WebGPU backend#20925

Merged
meta-codesync[bot] merged 6 commits into
gh/JCNTH/64/basefrom
gh/JCNTH/64/head
Jul 21, 2026
Merged

[ExecuTorch][WebGPU] Add select/boolean ops (where, scalar compares, logical_not) to the WebGPU backend#20925
meta-codesync[bot] merged 6 commits into
gh/JCNTH/64/basefrom
gh/JCNTH/64/head

Conversation

@JCNTH

@JCNTH JCNTH commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Add aten.where.self, scalar comparisons (aten.{eq,ne,le,ge,lt,gt}.Scalar), and aten.logical_not.default handlers for the training tail. The scalar compares and logical_not are generated from ONE templated byte-packed-bool shader (runtime/ops/boolean_op/) rather than per-op hand-written kernels — mirroring the binary_op codegen and Vulkan's grouping of comparison ops as ${OPERATOR} variants (backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml).

Key changes:

  • runtime/ops/boolean_op/ — one boolean_op.wgsl template + boolean_op.yaml (variants compare_{eq,ne,le,ge,lt,gt} + logical_not) expand to the per-variant *_wgsl.h; BooleanOp.cpp holds one shared dispatch_bool_op helper (pack 4 bools per u32 word, one thread per word) plus the seven WEBGPU_REGISTER_OPs.
  • runtime/ops/where/ — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
  • op_registry.py — register the net-new aten.{ne,lt,le,ge,gt}.Scalar + aten.logical_not.default OpFeatures (eq.Scalar already on master).
  • CMakeLists.txt WEBGPU_SRCS — wire boolean_op/BooleanOp.cpp.

aten.where.self already had Vulkan OpFeatures; the scalar-compare + logical_not registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
@exported-using-ghexport

Differential Revision: D111755122

Differential Revision: D111755122

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/20925

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure, 1 Unrelated Failure, 6 Unclassified Failures

As of commit 9127593 with merge base 21554e5 (image):

NEW FAILURE - The following job has failed:

UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:

FLAKY - The following job failed but was likely due to flakiness present on trunk:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 14, 2026
This was referenced Jul 14, 2026

@SS-JIA SS-JIA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

[ghstack-poisoned]
[ghstack-poisoned]

@SS-JIA SS-JIA left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

[ghstack-poisoned]
@meta-codesync
meta-codesync Bot merged commit 7ba6cf7 into gh/JCNTH/64/base Jul 21, 2026
178 of 189 checks passed
@meta-codesync
meta-codesync Bot deleted the gh/JCNTH/64/head branch July 21, 2026 16:22
@meta-codesync
meta-codesync Bot temporarily deployed to cherry-pick-bot July 21, 2026 16:22 Inactive
JCNTH added a commit that referenced this pull request Jul 21, 2026
…logical_not) to the WebGPU backend

Pull Request resolved: #20925

Add `aten.where.self`, scalar comparisons (`aten.{eq,ne,le,ge,lt,gt}.Scalar`), and `aten.logical_not.default` handlers for the training tail. The scalar compares and `logical_not` are generated from ONE templated byte-packed-bool shader (`runtime/ops/boolean_op/`) rather than per-op hand-written kernels — mirroring the `binary_op` codegen and Vulkan's grouping of comparison ops as `${OPERATOR}` variants (`backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml`).

Key changes:
- `runtime/ops/boolean_op/` — one `boolean_op.wgsl` template + `boolean_op.yaml` (variants `compare_{eq,ne,le,ge,lt,gt}` + `logical_not`) expand to the per-variant `*_wgsl.h`; `BooleanOp.cpp` holds one shared `dispatch_bool_op` helper (pack 4 bools per `u32` word, one thread per word) plus the seven `WEBGPU_REGISTER_OP`s.
- `runtime/ops/where/` — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
- `op_registry.py` — register the net-new `aten.{ne,lt,le,ge,gt}.Scalar` + `aten.logical_not.default` `OpFeatures` (`eq.Scalar` already on master).
- `CMakeLists.txt` `WEBGPU_SRCS` — wire `boolean_op/BooleanOp.cpp`.

`aten.where.self` already had Vulkan `OpFeatures`; the scalar-compare + `logical_not` registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
ghstack-source-id: 405026062
@exported-using-ghexport

Differential Revision: [D111755122](https://our.internmc.facebook.com/intern/diff/D111755122/)
JCNTH added a commit that referenced this pull request Jul 21, 2026
…logical_not) to the WebGPU backend

Pull Request resolved: #20925

Add `aten.where.self`, scalar comparisons (`aten.{eq,ne,le,ge,lt,gt}.Scalar`), and `aten.logical_not.default` handlers for the training tail. The scalar compares and `logical_not` are generated from ONE templated byte-packed-bool shader (`runtime/ops/boolean_op/`) rather than per-op hand-written kernels — mirroring the `binary_op` codegen and Vulkan's grouping of comparison ops as `${OPERATOR}` variants (`backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml`).

Key changes:
- `runtime/ops/boolean_op/` — one `boolean_op.wgsl` template + `boolean_op.yaml` (variants `compare_{eq,ne,le,ge,lt,gt}` + `logical_not`) expand to the per-variant `*_wgsl.h`; `BooleanOp.cpp` holds one shared `dispatch_bool_op` helper (pack 4 bools per `u32` word, one thread per word) plus the seven `WEBGPU_REGISTER_OP`s.
- `runtime/ops/where/` — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
- `op_registry.py` — register the net-new `aten.{ne,lt,le,ge,gt}.Scalar` + `aten.logical_not.default` `OpFeatures` (`eq.Scalar` already on master).
- `CMakeLists.txt` `WEBGPU_SRCS` — wire `boolean_op/BooleanOp.cpp`.

`aten.where.self` already had Vulkan `OpFeatures`; the scalar-compare + `logical_not` registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
ghstack-source-id: 405026062
@exported-using-ghexport

Differential Revision: [D111755122](https://our.internmc.facebook.com/intern/diff/D111755122/)
JCNTH added a commit that referenced this pull request Jul 21, 2026
…logical_not) to the WebGPU backend

Pull Request resolved: #20925

Add `aten.where.self`, scalar comparisons (`aten.{eq,ne,le,ge,lt,gt}.Scalar`), and `aten.logical_not.default` handlers for the training tail. The scalar compares and `logical_not` are generated from ONE templated byte-packed-bool shader (`runtime/ops/boolean_op/`) rather than per-op hand-written kernels — mirroring the `binary_op` codegen and Vulkan's grouping of comparison ops as `${OPERATOR}` variants (`backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml`).

Key changes:
- `runtime/ops/boolean_op/` — one `boolean_op.wgsl` template + `boolean_op.yaml` (variants `compare_{eq,ne,le,ge,lt,gt}` + `logical_not`) expand to the per-variant `*_wgsl.h`; `BooleanOp.cpp` holds one shared `dispatch_bool_op` helper (pack 4 bools per `u32` word, one thread per word) plus the seven `WEBGPU_REGISTER_OP`s.
- `runtime/ops/where/` — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
- `op_registry.py` — register the net-new `aten.{ne,lt,le,ge,gt}.Scalar` + `aten.logical_not.default` `OpFeatures` (`eq.Scalar` already on master).
- `CMakeLists.txt` `WEBGPU_SRCS` — wire `boolean_op/BooleanOp.cpp`.

`aten.where.self` already had Vulkan `OpFeatures`; the scalar-compare + `logical_not` registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
ghstack-source-id: 405026062
@exported-using-ghexport

Differential Revision: [D111755122](https://our.internmc.facebook.com/intern/diff/D111755122/)
JCNTH added a commit that referenced this pull request Jul 21, 2026
…logical_not) to the WebGPU backend

Pull Request resolved: #20925

Add `aten.where.self`, scalar comparisons (`aten.{eq,ne,le,ge,lt,gt}.Scalar`), and `aten.logical_not.default` handlers for the training tail. The scalar compares and `logical_not` are generated from ONE templated byte-packed-bool shader (`runtime/ops/boolean_op/`) rather than per-op hand-written kernels — mirroring the `binary_op` codegen and Vulkan's grouping of comparison ops as `${OPERATOR}` variants (`backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml`).

Key changes:
- `runtime/ops/boolean_op/` — one `boolean_op.wgsl` template + `boolean_op.yaml` (variants `compare_{eq,ne,le,ge,lt,gt}` + `logical_not`) expand to the per-variant `*_wgsl.h`; `BooleanOp.cpp` holds one shared `dispatch_bool_op` helper (pack 4 bools per `u32` word, one thread per word) plus the seven `WEBGPU_REGISTER_OP`s.
- `runtime/ops/where/` — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
- `op_registry.py` — register the net-new `aten.{ne,lt,le,ge,gt}.Scalar` + `aten.logical_not.default` `OpFeatures` (`eq.Scalar` already on master).
- `CMakeLists.txt` `WEBGPU_SRCS` — wire `boolean_op/BooleanOp.cpp`.

`aten.where.self` already had Vulkan `OpFeatures`; the scalar-compare + `logical_not` registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
ghstack-source-id: 405026062
@exported-using-ghexport

Differential Revision: [D111755122](https://our.internmc.facebook.com/intern/diff/D111755122/)
JCNTH added a commit that referenced this pull request Jul 21, 2026
…logical_not) to the WebGPU backend

Pull Request resolved: #20925

Add `aten.where.self`, scalar comparisons (`aten.{eq,ne,le,ge,lt,gt}.Scalar`), and `aten.logical_not.default` handlers for the training tail. The scalar compares and `logical_not` are generated from ONE templated byte-packed-bool shader (`runtime/ops/boolean_op/`) rather than per-op hand-written kernels — mirroring the `binary_op` codegen and Vulkan's grouping of comparison ops as `${OPERATOR}` variants (`backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml`).

Key changes:
- `runtime/ops/boolean_op/` — one `boolean_op.wgsl` template + `boolean_op.yaml` (variants `compare_{eq,ne,le,ge,lt,gt}` + `logical_not`) expand to the per-variant `*_wgsl.h`; `BooleanOp.cpp` holds one shared `dispatch_bool_op` helper (pack 4 bools per `u32` word, one thread per word) plus the seven `WEBGPU_REGISTER_OP`s.
- `runtime/ops/where/` — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
- `op_registry.py` — register the net-new `aten.{ne,lt,le,ge,gt}.Scalar` + `aten.logical_not.default` `OpFeatures` (`eq.Scalar` already on master).
- `CMakeLists.txt` `WEBGPU_SRCS` — wire `boolean_op/BooleanOp.cpp`.

`aten.where.self` already had Vulkan `OpFeatures`; the scalar-compare + `logical_not` registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
ghstack-source-id: 405026062
@exported-using-ghexport

Differential Revision: [D111755122](https://our.internmc.facebook.com/intern/diff/D111755122/)
JCNTH added a commit that referenced this pull request Jul 21, 2026
…logical_not) to the WebGPU backend

Pull Request resolved: #20925

Add `aten.where.self`, scalar comparisons (`aten.{eq,ne,le,ge,lt,gt}.Scalar`), and `aten.logical_not.default` handlers for the training tail. The scalar compares and `logical_not` are generated from ONE templated byte-packed-bool shader (`runtime/ops/boolean_op/`) rather than per-op hand-written kernels — mirroring the `binary_op` codegen and Vulkan's grouping of comparison ops as `${OPERATOR}` variants (`backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml`).

Key changes:
- `runtime/ops/boolean_op/` — one `boolean_op.wgsl` template + `boolean_op.yaml` (variants `compare_{eq,ne,le,ge,lt,gt}` + `logical_not`) expand to the per-variant `*_wgsl.h`; `BooleanOp.cpp` holds one shared `dispatch_bool_op` helper (pack 4 bools per `u32` word, one thread per word) plus the seven `WEBGPU_REGISTER_OP`s.
- `runtime/ops/where/` — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
- `op_registry.py` — register the net-new `aten.{ne,lt,le,ge,gt}.Scalar` + `aten.logical_not.default` `OpFeatures` (`eq.Scalar` already on master).
- `CMakeLists.txt` `WEBGPU_SRCS` — wire `boolean_op/BooleanOp.cpp`.

`aten.where.self` already had Vulkan `OpFeatures`; the scalar-compare + `logical_not` registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
ghstack-source-id: 405026062
@exported-using-ghexport

Differential Revision: [D111755122](https://our.internmc.facebook.com/intern/diff/D111755122/)
JCNTH added a commit that referenced this pull request Jul 21, 2026
…logical_not) to the WebGPU backend

Pull Request resolved: #20925

Add `aten.where.self`, scalar comparisons (`aten.{eq,ne,le,ge,lt,gt}.Scalar`), and `aten.logical_not.default` handlers for the training tail. The scalar compares and `logical_not` are generated from ONE templated byte-packed-bool shader (`runtime/ops/boolean_op/`) rather than per-op hand-written kernels — mirroring the `binary_op` codegen and Vulkan's grouping of comparison ops as `${OPERATOR}` variants (`backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml`).

Key changes:
- `runtime/ops/boolean_op/` — one `boolean_op.wgsl` template + `boolean_op.yaml` (variants `compare_{eq,ne,le,ge,lt,gt}` + `logical_not`) expand to the per-variant `*_wgsl.h`; `BooleanOp.cpp` holds one shared `dispatch_bool_op` helper (pack 4 bools per `u32` word, one thread per word) plus the seven `WEBGPU_REGISTER_OP`s.
- `runtime/ops/where/` — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
- `op_registry.py` — register the net-new `aten.{ne,lt,le,ge,gt}.Scalar` + `aten.logical_not.default` `OpFeatures` (`eq.Scalar` already on master).
- `CMakeLists.txt` `WEBGPU_SRCS` — wire `boolean_op/BooleanOp.cpp`.

`aten.where.self` already had Vulkan `OpFeatures`; the scalar-compare + `logical_not` registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
ghstack-source-id: 405026062
@exported-using-ghexport

Differential Revision: [D111755122](https://our.internmc.facebook.com/intern/diff/D111755122/)
JCNTH added a commit that referenced this pull request Jul 21, 2026
…logical_not) to the WebGPU backend

Pull Request resolved: #20925

Add `aten.where.self`, scalar comparisons (`aten.{eq,ne,le,ge,lt,gt}.Scalar`), and `aten.logical_not.default` handlers for the training tail. The scalar compares and `logical_not` are generated from ONE templated byte-packed-bool shader (`runtime/ops/boolean_op/`) rather than per-op hand-written kernels — mirroring the `binary_op` codegen and Vulkan's grouping of comparison ops as `${OPERATOR}` variants (`backends/vulkan/runtime/graph/ops/glsl/binary_op_buffer.yaml`).

Key changes:
- `runtime/ops/boolean_op/` — one `boolean_op.wgsl` template + `boolean_op.yaml` (variants `compare_{eq,ne,le,ge,lt,gt}` + `logical_not`) expand to the per-variant `*_wgsl.h`; `BooleanOp.cpp` holds one shared `dispatch_bool_op` helper (pack 4 bools per `u32` word, one thread per word) plus the seven `WEBGPU_REGISTER_OP`s.
- `runtime/ops/where/` — ternary select, kept as its own kernel/handler (non-bool-family, as in Vulkan).
- `op_registry.py` — register the net-new `aten.{ne,lt,le,ge,gt}.Scalar` + `aten.logical_not.default` `OpFeatures` (`eq.Scalar` already on master).
- `CMakeLists.txt` `WEBGPU_SRCS` — wire `boolean_op/BooleanOp.cpp`.

`aten.where.self` already had Vulkan `OpFeatures`; the scalar-compare + `logical_not` registrations are additive to the shared Vulkan registry.

Co-authored-with: Claude Code.
ghstack-source-id: 405026062
@exported-using-ghexport

Differential Revision: [D111755122](https://our.internmc.facebook.com/intern/diff/D111755122/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants